<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>商品入库</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .form-container {
            max-width: 500px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            border-radius: 4px;
        }
        h2 {
            color: #333;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input, select {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            padding: 10px 15px;
            background: #28a745;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
            font-size: 16px;
        }
        button:hover {
            background: #218838;
        }
        .stock-info {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }
    </style>
</head>
<body>
<div class="form-container">
    <h2>商品入库</h2>
    <form id="stockInForm">
        <div class="form-group">
            <label for="productSelect">选择商品</label>
            <select id="productSelect" required>
                <option value="">-- 请选择商品 --</option>
                <option value="P1001">iPhone 13</option>
                <option value="P1002">MacBook Pro</option>
            </select>
        </div>
        <div class="form-group">
            <label for="quantity">入库数量</label>
            <input type="number" id="quantity" min="1" required>
        </div>
        <div class="form-group">
            <label for="operator">操作人</label>
            <input type="text" id="operator" required>
        </div>
        <div class="form-group">
            <label for="remark">备注</label>
            <input type="text" id="remark" placeholder="可选">
        </div>
        <button type="submit">提交入库</button>
    </form>
</div>

<script>
    document.getElementById('stockInForm').addEventListener('submit', function(e) {
        e.preventDefault();
        const productName = document.getElementById('productSelect').options[document.getElementById('productSelect').selectedIndex].text;
        const quantity = document.getElementById('quantity').value;
        alert(`商品【${productName}】入库${quantity}件成功！`);
        this.reset();
    });

    document.getElementById('productSelect').addEventListener('change', function() {
        // 实际项目中这里会获取商品库存信息
        if(this.value === 'P1001') {
            document.getElementById('quantity').value = '10';
        } else if(this.value === 'P1002') {
            document.getElementById('quantity').value = '5';
        }
    });
</script>
</body>
</html>